package com.gaoyang.thread;

import com.gaoyang.domain.GongHuiUser;
import com.gaoyang.task.GonghuiTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class GonghuiThread extends Thread {

    private GongHuiUser user;

    private GonghuiTask task;

    private static Logger logger = LogManager.getLogger(GonghuiThread.class);

    //26359 朝阳活动
    public static String gonghui_actId = "31153";
    public static String gonghui_count = "1";
    public static String gonghui_firm_id = "";

    public GonghuiThread(GongHuiUser user, GonghuiTask task) {
        this.user = user;
        this.task = task;
    }
    
    @Override
    public void run() {
        try {
            ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
            while (true) {
                fixedThreadPool.execute(new Runnable() {
                    @Override
                    public void run() {
                        try {
//                            logger.info(user.getUserName() + user.getToken() + Thread.currentThread().getName());
                            task.reportGonghuiListInfo(gonghui_actId, gonghui_count, user, gonghui_firm_id);
//                            task.reportGonghuiInfo(gonghui_actId, gonghui_count, user, gonghui_firm_id);
//                            task.reportGonghuiInfo("28356", "1", user, GonghuiThread.gonghui_firm_id);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
                try {
                    Thread.sleep(100);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}